package nl.project.data;

import nl.project.data.controller.MembersDAO;

import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.EntityNotFoundException;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;

public class Employee extends User {
	private int employeeId;
	
	public Employee(int id) throws EntityNotFoundException {
		this.employeeId = id;
		
		//get all info from this employee
		getEmployeeInfo();
	}

	/**
	 * Get all the info from a certain employee
	 * 
	 * @throws EntityNotFoundException
	 */

	private void getEmployeeInfo() throws EntityNotFoundException {
		Key k = KeyFactory.createKey("Employees", "Employees");
		Entity e = MembersDAO.getEntityInfo(this.employeeId, k, "employeeId", "Employee");
		this.initials = (String) e.getProperty("initials");
		this.firstName = (String) e.getProperty("firstName");
		this.surName = (String) e.getProperty("surName");
		this.title = (String) e.getProperty("title");
		this.preposition = (String) e.getProperty("preposition");
	}
}